package com.enen.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.enen.dao.OldDao;
import com.enen.domain.Old;
import com.enen.service.OldService;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class OldServiceImpl extends ServiceImpl<OldDao, Old> implements OldService {
    @Autowired
    private OldDao oldDao;


    @Override
    public IPage selectByPage(int current, int pages,Old old)  {

        IPage page = new Page(current,pages);
        LambdaQueryWrapper<Old> lqw = new LambdaQueryWrapper<Old>();
        lqw.like(Strings.isNotEmpty(old.getOldName()),Old::getOldName,old.getOldName());
        IPage page1 = oldDao.selectPage(page, lqw);
        return page1;
    }

    @Override
    public Old selectByPhone(String phone) {
        LambdaQueryWrapper<Old> lqw = new LambdaQueryWrapper<>();
        lqw.like(Strings.isNotEmpty(phone),Old::getOldPhone,phone);
        return oldDao.selectOne(lqw);
    }
}
